#!/bin/bash

#!/bin/bash

#//////////////////////////////////////////////////////////////////////////////////
#
#  Betsu-Banner, ICG Module. - v0.0.1 | The Betsu Project
#
#//////////////////////////////////////////////////////////////////////////////////
#
#  Copyright (c) 2022, Alexa Hattori <unixcat@anche.no>
#  All rights reserved.
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions are met:
#
#  * Redistributions of source code must retain the above copyright notice, this
#   list of conditions and the following disclaimer.
#
#  * Redistributions in binary form must reproduce the above copyright notice,
#   this list of conditions and the following disclaimer in the documentation
#   and/or other materials provided with the distribution.
#
#  * Neither the name of the copyright holder nor the names of its
#   contributors may be used to endorse or promote products derived from
#   this software without specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
#  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
#  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
#  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
#  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
#  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
#  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
#  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#//////////////////////////////////////////////////////////////////////////////////
#
#  Module Authors:
#  Alexa Hattori <unixcat@anche.no>.
#
#//////////////////////////////////////////////////////////////////////////////////

MODULE_VERSION="v0.0.1"
COMPATIBLE_WITH="v0.1.5-exp"

icg_main () {
    echo "###################################"
    echo "Interactive Config Generator v0.0.1"
    echo "	   External Module           "
    echo "###################################"
    echo "Do you want to generate new Configuration File in Interactive Mode?"
    select yn in "Yes" "No"; do
	case $yn in
	    "Yes" ) clear; icg_start; break;;
	    "No" ) exit;;
	esac
    done
}

icg_start ()  {
    echo "[ ICG ] Starting Interactive Mode ..."
    echo "
    # Betsu-Banner v0.1.5-exp Configuration File
    # $HOME/.betsu/banner/banner.cfg
    # Generated by ICG External Module
    
    # Header Settings    
    " > $HOME/.betsu/banner/banner.cfg
    icg_header
}

icg_header () {
    echo ""
    echo "###############"
    echo "Header Settings"
    echo "###############"
    echo ""
    # Date Format
    echo "What date format do you want to use?"
    select date_format in "12-hour" "24-hour"; do
	case $date_format in
	    "12-hour" ) echo "date_format='12'" >> $HOME/.betsu/banner/banner.cfg; break;;
	    "24-hour" ) echo "date_format='24'" >> $HOME/.betsu/banner/banner.cfg; break;;
	esac
    done
    echo ""
    echo "Do you want to show large Betsu logo?"
    select betsu_logo in "Yes" "No"; do
	case $betsu_logo in
	    "Yes" ) echo "ascii_betsu_logo='true'" >> $HOME/.betsu/banner/banner.cfg; break;;
	    "No" ) echo "ascii_betsu_logo='false'" >> $HOME/.betsu/banner/banner.cfg; break;;
	esac
    done
    echo "" >> $HOME/.betsu/banner/banner.cfg
    echo "# First Block" >> $HOME/.betsu/banner/banner.cfg
    echo "" >> $HOME/.betsu/banner/banner.cfg
    icg_first_block
}

icg_first_block () {
    echo ""
    echo "###########"
    echo "First Block"
    echo "###########"
    echo ""
    echo "Do you want to show CPU Temperature?"
    select yn in "Yes" "No"; do
	case $yn in
	    "Yes" ) echo "cpu_temp='true'" >> $HOME/.betsu/banner/banner.cfg; break;;
	    "No" ) echo "cpu_temp='false'" >> $HOME/.betsu/banner/banner.cfg; break;;
	esac
    done
    echo "Do you want to show RAM Usage?"
    select yn in "Yes" "No"; do
	case $yn in
	    "Yes" ) echo "ram_usage='true'" >> $HOME/.betsu/banner/banner.cfg; break;;
	    "No" ) echo "ram_usage='false'" >> $HOME/.betsu/banner/banner.cfg; break;;
	esac
    done
    echo "Do you want to show SWAP Usage?"
    select yn in "Yes" "No"; do
	case $yn in
	    "Yes" ) echo "swap_usage='true'" >> $HOME/.betsu/banner/banner.cfg; break;;
	    "No" ) echo "swap_usage='false'" >> $HOME/.betsu/banner/banner.cfg; break;;
	esac
    done
    echo "Do you want to show Battery Percentage?"
    select yn in "Yes" "No"; do
	case $yn in
	    "Yes" ) echo "battery='true'" >> $HOME/.betsu/banner/banner.cfg; break;;
	    "No" ) echo "battery='false'" >> $HOME/.betsu/banner/banner.cfg; break;;
	esac
    done
    echo "Do you want to show uptime?"
    select yn in "Yes" "No"; do
	case $yn in
	    "Yes" ) echo "uptime='true'" >> $HOME/.betsu/banner/banner.cfg; break;;
	    "No" ) echo "uptime='false'" >> $HOME/.betsu/banner/banner.cfg; break;;
	esac
    done
    echo "" >> $HOME/.betsu/banner/banner.cfg; 
    echo "# Storage" >> $HOME/.betsu/banner/banner.cfg; 
    echo "" >> $HOME/.betsu/banner/banner.cfg; 
    icg_storage
}

icg_storage () {
    echo "Do you want to show RootFS Disk Usage?"
    select yn in "Yes" "No"; do
	case $yn in
	    "Yes" ) echo "rootfs='true'" >> $HOME/.betsu/banner/banner.cfg; break;;
	    "No" ) echo "rootfs='false'" >> $HOME/.betsu/banner/banner.cfg; break;;
	esac
    done
    echo "Do you want to show Userspace Disk Usage?"
    select yn in "Yes" "No"; do
	case $yn in
	    "Yes" ) echo "userspace='true'" >> $HOME/.betsu/banner/banner.cfg; break;;
	    "No" ) echo "userspace='false'" >> $HOME/.betsu/banner/banner.cfg; break;;
	esac
    done
    echo "" >> $HOME/.betsu/banner/banner.cfg; 
    echo "## Custom" >> $HOME/.betsu/banner/banner.cfg; 
    echo "" >> $HOME/.betsu/banner/banner.cfg; 
    echo "Do yo want to enable Custom Mountpoint for Disk Usage?"
    select yn in "Yes" "No"; do
	case $yn in
	    "Yes" ) echo "enable_custom_mountpoint='true'" >> $HOME/.betsu/banner/banner.cfg;
		    read -p "Enter mountpoint: " custom_mountpoint;
		    echo "custom_mountpoint='$custom_mountpoint'" >> $HOME/.betsu/banner/banner.cfg;
		    break;;
	    "No" ) echo "enable_custom_mountpoint='false'" >> $HOME/.betsu/banner/banner.cfg;
		   echo "custom_mountpoint='REPLACE_ME'" >> $HOME/.betsu/banner/banner.cfg;
		   break;;
	esac
    done
    echo "" >> $HOME/.betsu/banner/banner.cfg
    echo "# Custom Entry" >> $HOME/.betsu/banner/banner.cfg
    echo "" >> $HOME/.betsu/banner/banner.cfg
    echo "Do you want to enable Custom Entry?"
    select yn in "Yes" "No"; do
	case $yn in
	    "Yes" ) icg_custom_entry; break;;
	    "No" ) echo "enable_custom_entry='false'" >> $HOME/.betsu/banner/banner.cfg;
		   echo "custom_entry_text='Custom'" >> $HOME/.betsu/banner/banner.cfg;
		   echo "custom_entry_command='echo Hello, world!'" >> $HOME/.betsu/banner/banner.cfg;
		   icg_network; break;;
	esac
    done
}

icg_custom_entry () {
    echo "enable_custom_entry='true'" >> $HOME/.betsu/banner/banner.cfg
    echo ""
    echo "############"
    echo "Custom Entry"
    echo "############"
    echo ""
    read -p "Enter text for Custom Entry: " custom_text
    echo "custom_entry_text='$custom_text'" >> $HOME/.betsu/banner/banner.cfg
    read -p "Enter command for Custom Entry: " custom_command
    echo "custom_entry_command='$custom_command'" >> $HOME/.betsu/banner/banner.cfg
    icg_network
}

icg_network () {
    echo "nop"
}

icg_main
